<%-- 
    Document   : login
    Created on : 2020-6-15, 19:20:50
    Author     : 阿椋世界第二可爱
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.net.URLDecoder"%>

<!DOCTYPE html>
<html>
    <head>
        <title>欢迎登录系统</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="login.css" type="text/css">
  
    </head>
<body>
<%
String deal=(String)request.getAttribute("error");
if(deal!=null)
	out.println(deal);
%>

<%
//获取请求相关的cookie
Cookie[] cookies = request.getCookies();//返回所有Cookie对象 
//用户名和密码
String username = ""; //声明姓名，赋空字符串
String password = ""; //声明密码，赋空字符串给password

//判断cookie是否存在
if(cookies != null){ //如果Cookie不为空即存在
for(int i=0;i<cookies.length;i++){ //遍历所有Cookie
if(cookies[i].getName().equals("username")){ //如果存在Cookie名字为username
//username = cookies[i].getValue();
username = URLDecoder.decode(cookies[i].getValue(), "utf-8"); //则将名为username的属性值赋值给username
}
if(cookies[i].getName().equals("password")){ //如果存在Cookie名字为password
password = cookies[i].getValue(); //则将此Cookie的值赋给password
}
}//后面在客户端显示各Cookie的属性值
}
%>
<form name="Getpost" action="Getpost" method="post">

    <div id="login">  
        <h1>Login</h1>  
            <input type="text" required="required" placeholder="用户名"  autocomplete="off" name="username" value="<%=username%>" >
            <input type="password" required="required" placeholder="密码" name="password" value="<%=password%>"> 
            <button class="button" type="submit">登录</button>
            <input type="checkbox" name="radiobutton"  value="radiobutton" checked ><label for="radiobutton">记住密码</label>
    </div> 

</form>
</body>  

</html>

